home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Dev / GameboyDev / GBDK / include / sys / malloc.h
Encoding:
C/C++ Source or Header  |  1999-03-29  |  1.1 KB  |  45 lines

  1. /*
  2.   sys/malloc.h
  3.  
  4.   Header for a simple implementation of malloc()
  5. */
  6. #ifndef __SYS_MALLOC_H
  7. #define __SYS_MALLOC_H
  8.  
  9. #include <types.h>
  10.  
  11. /* The various constants */
  12. /* The malloc hunk flags
  13.    Note:  Cound have used a negative size a'la TI
  14. */
  15. #define MALLOC_FREE    1
  16. #define MALLOC_USED    2
  17.  
  18. /* Magic number of a header.  Gives us some chance of surviving if the list
  19.    is corrupted*/
  20. #define MALLOC_MAGIC    123
  21.  
  22. /* malloc hunk header definition */
  23. typedef struct smalloc_hunk    mmalloc_hunk;
  24. typedef struct smalloc_hunk *    pmmalloc_hunk;
  25.  
  26. struct smalloc_hunk {
  27.     UBYTE         magic;        /* Magic number - indicates valid hunk header */
  28.     pmmalloc_hunk    next;        /* Pointer to the next hunk */
  29.     UWORD         size;        /* Size in bytes of this region */
  30.     int         status;        /* One of MALLOC_FREE or MALLOC_USED */
  31. };
  32.  
  33. /* Start of free memory, as defined by the linker */
  34. extern UBYTE malloc_heap_start;
  35.  
  36. /* First hunk */
  37. extern pmmalloc_hunk malloc_first;
  38.  
  39. /* Garbage collect (join free hunks) */
  40. void malloc_gc(void);
  41. /* debug message logger */
  42. void debug( char *routine, char *msg );
  43.  
  44. #endif    /* __SYS_MALLOC_H */
  45.